package conMgr.ui.bases;

import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.event.WindowEvent;

import javax.swing.JDialog;

public abstract class JDialogEx extends JDialog
{
	/**
	 * The serialization ID for this class.
	 */
	private static final long serialVersionUID = 5331045989206973278L;

	/**
	 * Initializes a new dialog.
	 */
	protected JDialogEx()
	{
		setModal(true);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setLayout(new GridBagLayout());
		setBackground(Color.WHITE);
	}
	
	/**
	 * Closes the window.
	 */
	protected void close()
	{
		dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
	}
	
	/**
	 * Finalizes the setup for this dialog by packing and centering the dialog.
	 */
	protected void finishSetup()
	{
		pack();
		setLocationRelativeTo(null);
	}
}
